﻿//------------------------------------------------------------------------------
//  
//------------------------------------------------------------------------------
#region Imported Namespaces
using System;
using System.IO;
using System.Xml.Serialization;
using System.Data;
using System.Configuration;
using System.Collections;

using SSRS;
using PHSRAG.Insight21.Reports;
using PHSRAG.Insight21.InsightUtilities;
using Utils = PHSRAG.Insight21.InsightUtilities;
using PHSRAG.Insight21.SearchContext;
//using UserContext = PHSRAG.Insight21.Context.UserContext;
using AgreementsConstants = PHSRAG.Insight21.InsightUtilities.Constants.AgreementsConstants;

#endregion

namespace PHSRAG.Insight21.Agreements.Reports
{


    public class sqlPatientCareDetailsReport : sqlReport
    {
        public sqlPatientCareDetailsReport(string pageUrl) : base(pageUrl) { }
       
        public override ParameterValue[] setParameters(ref string rptName)
        {
            CommonSearchContext searchContext = cachePolicy.GetCachedObject(CommonSearchContext.CacheKey) as CommonSearchContext;
            Hashtable gridProperties = cachePolicy.GetCachedObject(Keys.PatientCareDetailsPageKey) as Hashtable;
            SearchCriteria crit = searchContext.GetSearchCriteria(pageUrl);

            ArrayList reportParams = new ArrayList();

            ParameterValue paramValue = new ParameterValue();
            paramValue.Name = "fundNumber";
            paramValue.Value = crit[Constants.FundNumberKey];
            reportParams.Add(paramValue);

            if (crit[Constants.PatientMRNKey] != null)
            {
                paramValue = new ParameterValue();
                paramValue.Name = "patientMRN";
                paramValue.Value = crit[Constants.PatientMRNKey];
                reportParams.Add(paramValue);
            }

            if (crit[Constants.FirstNameKey] != null)
            {
                paramValue = new ParameterValue();
                paramValue.Name = "patientFirstName";
                paramValue.Value = crit[Constants.FirstNameKey];
                reportParams.Add(paramValue);
            }

            if (crit[Constants.LastNameKey] != null)
            {
                paramValue = new ParameterValue();
                paramValue.Name = "patientLastName";
                paramValue.Value = crit[Constants.LastNameKey];
                reportParams.Add(paramValue);
            }

            if (crit[Constants.ChargeCodeKey] != null)
            {
                paramValue = new ParameterValue();
                paramValue.Name = "chargeCode";
                paramValue.Value = crit[Constants.ChargeCodeKey];
                reportParams.Add(paramValue);
            }

            if (crit[Constants.InstitutionalMRNKey] != null)
            {
                paramValue = new ParameterValue();
                paramValue.Name = "fundMRN";
                paramValue.Value = crit[Constants.InstitutionalMRNKey];
                reportParams.Add(paramValue);
            }

            if (crit[Constants.PostFromDateKey] != null)
            {
                paramValue = new ParameterValue();
                paramValue.Name = "postFromDate";
                paramValue.Value = crit[Constants.PostFromDateKey];
                reportParams.Add(paramValue);
            }

            if (crit[Constants.PostToDateKey] != null)
            {
                paramValue = new ParameterValue();
                paramValue.Name = "postToDate";
                paramValue.Value = crit[Constants.PostToDateKey];
                reportParams.Add(paramValue);
            }

            if (crit[Constants.ServiceFromDateKey] != null)
            {
                paramValue = new ParameterValue();
                paramValue.Name = "serviceFromDate";
                paramValue.Value = crit[Constants.ServiceFromDateKey];
                reportParams.Add(paramValue);
            }

            if (crit[Constants.ServiceToDateKey] != null)
            {
                paramValue = new ParameterValue();
                paramValue.Name = "serviceToDate";
                paramValue.Value = crit[Constants.ServiceToDateKey];
                reportParams.Add(paramValue);
            }

            if (crit["daily"] != null)
            {
                paramValue = new ParameterValue();
                paramValue.Name = "daily";
                paramValue.Value = crit["daily"];
                reportParams.Add(paramValue);
            }

            paramValue = new ParameterValue();
            paramValue.Name = "sortColumn";
            paramValue.Value = gridProperties[Keys.GridBasePageSortColumnKey].ToString( );
            reportParams.Add(paramValue);

            paramValue = new ParameterValue();
            paramValue.Name = "sortAscending";
            paramValue.Value = gridProperties[Keys.GridBasePageSortOrderKey].ToString( );
            reportParams.Add(paramValue);

            ParameterValue[] oInputPrms = (ParameterValue[])reportParams.ToArray(typeof(ParameterValue));

            return oInputPrms;
        }
    }
}
